/**
 * http://blog.csdn.net/xukai871105/article/details/39213061
 * 
 */
var coap = require('coap'); 
var bl = require('bl');  
var req = coap.request({  
    host : "localhost",
    port : '5683',
    pathname: '/',  
    options: {  
        'Accept': 'application/json'  
    }  
});  
  
req.on('response', function(res) {  
    console.log('response code', res.code);  
  
    if (res.code !== '2.05') return process.exit(1);  
  
    res.pipe(bl(function(err, data) {  
        var json = JSON.parse(data);  
        console.log(json);  
        process.exit(0);  
    }))  
});  
  
req.end();  


